
const express = require('express');
const socketIo = require('socket.io');
const app = express();
const server = require('http').createServer(app);
const io = socketIo(server);
server.listen(5000,()=>{
    console.log('服务器运行中')
});
//const httpserver = http.createServer().listen(4000);
//const io = require('socket.io').listen(server);
//const io = socket.listen(server);

 
 io.on('connection',(client)=>{
    client.on('logined',(data)=>{
        //console.log(data);
        io.emit('welcome',{message:data.message})
    });
     client.on('onmessage',(data)=>{
         //console.log(data)
         io.emit('backme',{text:data.text,face:data.face,uname:data.uname})
     })
});  

exports:io